import Vue from 'vue'
import Vuex from 'vuex'
import {CHANGE} from "./mutation-types";

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        flavor: ''
    },
    mutations: {
        [CHANGE](state, flavor) {
            state.flavor = flavor;
        }
    },
    //异步的，可以不使用
    actions: {
        [CHANGE](context, payload) {
            console.log(payload);
            context.commit(CHANGE, payload)
        }
    },
    getters: {
        flavor: state => state.flavor
    }
})
